# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-pydes
pkgname=('python2-pydes' 'python-pydes')
_pkgname=pyDes
pkgver=2.0.1
pkgrel=10
pkgdesc='Pure python implementation of DES and TRIPLE DES encryption algorithm.'
arch=('any')
url='https://pypi.org/project/pyDes/#files'
license=('custom:Public Domain')
makedepends=('python2-setuptools' 'python-setuptools' 'python2-pip' 'python-pip'
             'python2-wheel' 'python-wheel')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
        'LICENSE')
sha512sums=('9d2a048dd6f629713d93d5cfcf5eaccb45a28fd3942f6837baf492bc6d9f0fcd16a1611e467231e9abfa6756d1684b0848c2190195e9e772bed2e6574327885c'
            '5c9755f31433e5ee540049124fc7b6bdbb575eb682966247658424d0cc842cda92c9e8bc500e96462177ebeee71db993bbf9da75e3899eee1f00e48346d6c342')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}

  find "$_pkgname-$pkgver-2" -type f -name '*.py' |
  xargs sed -i 's|#!/usr/bin/python|#!/usr/bin/python2|'
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-pydes() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  install -Dm 644 ../LICENSE \
    "$pkgdir/usr/share/licenses/${pkgname[0]}/LICENSE"
}

package_python-pydes() {
  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  install -Dm 644 ../LICENSE \
    "$pkgdir/usr/share/licenses/${pkgname[1]}/LICENSE"
}

